﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace WindowsFormsApplication1
{
    public class Subject
    {
        public Subject() { }

       private List<Question> testQuestions;
       private string title;

       public string Title
       {
           get { return title; }
           set { title = value; }
       }

       internal List<Question> TestQuestions
        {
            get { return testQuestions; }
        }
       public Subject(string path, string t)
        {
            this.testQuestions = readQuestions(path);
            this.title = t;
        }

       private List<Question> readQuestions(string path)
       {
           string str = "";
           string[] info = new string[8];
           string[] variants = new string[6];
           List<Question> resultList = new List<Question>();
           Question content;
           FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
           StreamReader sr = new StreamReader(fs, Encoding.Default);
           while (!sr.EndOfStream)
           {
               str = sr.ReadLine();
               info = str.Split('/');
               content = new Question(info[0], info.Skip(1).Take(info.Length - 2).ToArray(), info.Last());
               resultList.Add(content);
           }
           fs.Close(); sr.Close();
           return resultList;
       }
    }

        
}
